package com.zebra.remoting.config;

import com.zebra.common.ZebraBaseMessage;
import io.netty.buffer.ByteBuf;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

@Data
@ToString
@NoArgsConstructor
public class ServerInfoMessage extends ZebraBaseMessage {
    private int serverId;
    private String inIP;
    private String outIP;
    private int port;

    @Override
    public void write(ByteBuf b) {
        writeInt(b, this.serverId);
        writeString(b, this.inIP);
        writeString(b, this.outIP);
        writeInt(b, this.port);
    }

    @Override
    public ServerInfoMessage read(ByteBuf b) {
        this.serverId = readInt(b);
        this.inIP = readString(b);
        this.outIP = readString(b);
        this.port = readInt(b);
        return this;
    }
}
